<?php
/**
 * 系统管理员列表
 * 处理视图所需的变量
 *
 */



// 保存数据框架名
$save_frame = $_SESSION[$G_admin_session_key]['save_frame'];
$back_url   = get_current_url();
// 将当前URL保存在Cookie中，避免复杂的URL字符串
cookie('back_url', strcode($back_url));
$url_cur    = get_current_url(array('orderby', 'desc'));
// 排序
$orderlist  = array('uid', 'username', 'realname', 'lasttime', 'createtime', 'valid');
$arr_orderby= parse_orderby($orderlist, 'uid', $url_cur);




$username   = trim(@$_GET['username']);
$valid      = @(int)$_GET['valid'];

$chk_valid_0= '';
$chk_valid_1= '';
$chk_valid_2= '';
if($valid == 2) {
    $chk_valid_2 = 'checked';
} elseif($valid == 1) {
    $chk_valid_1 = 'checked';
} else {
    $chk_valid_0 = 'checked';
}


// + -------------------------------------- + //
// 排序处理 - 为排序加上小图标

$order_by   = @trim($_GET['orderby']);
$order_desc = @(int)$_GET['desc'];

if($order_by != '') {
    $order_desc = ($order_desc!=1) ? 'sort_asc' : 'sort_desc' ;
    $this_param_style  = $order_by . '_style';
    $$this_param_style = '<div class="' . $order_desc . '"></div>';
}

// + -------------------------------------- + //

require($abs_admin_cppath . '/header.php');
?>

<div class="datacontainer1" id="listDiv">
<form action="<?php echo $mod_url['u.li']; ?>" name="search" method="get">
<div class="new_line" style="text-align:right">
	<div class="spW10 fl"></div>
	<a href="<?php echo $mod_url['u.add']; ?>" class="btn fl">新增系统用户</a>
	<input type="hidden" name="mod" value="<?php echo $mod; ?>">
	<input type="hidden" name="action" value="<?php echo $action; ?>">


	用户类型：
	<input type="radio" name="valid" id="valid_2" value="0" <?php echo $chk_valid_0; ?>> <label for="valid_2">所有用户</label> 
	<input type="radio" name="valid" id="valid_0" value="2" <?php echo $chk_valid_2; ?>> <label for="valid_0">禁用用户</label> 
	<input type="radio" name="valid" id="valid_1" value="1" <?php echo $chk_valid_1; ?>> <label for="valid_1">有效用户</label> 

&nbsp;&nbsp;
	用户名：
	<input type="text" name="username" value="<?php echo $username; ?>" size="20" class="text">

	<input type="submit" value="查询" class="btn">
	&nbsp;&nbsp;
</div>
</form>

<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" width="100%" class="list_table">
<form action="<?php echo $mod_url['u.del']; ?>" name="items_form" target="<?php echo $save_frame ?>" method="post" onsubmit="return submit_select_items(this.name, 'item_id[]');">
<THEAD>
	<TR class="list_head">
		<TH scope=col width="30"><a href="<?php echo $arr_orderby['uid']; ?>"><?php echo $uid_style;?>#</a></TH>
		<TH scope=col width="100"><a href="<?php echo $arr_orderby['username']; ?>"><?php echo $username_style;?>登录帐号</a></TH>
		<TH scope=col><a href="<?php echo $arr_orderby['realname']; ?>"><?php echo $realname_style;?>真实姓名</a></TH>
        <TH scope=col>权限</TH>
		<TH scope=col width="130"><a href="<?php echo $arr_orderby['lasttime']?>"><?php echo $lasttime_style;?>最近登录</a></TH>
		<TH scope=col width="80"><a href="<?php echo $arr_orderby['createtime']?>"><?php echo $createtime_style;?>创建时间</a></TH>
		<TH scope=col width="60"><a href="<?php echo $arr_orderby['valid']?>"><?php echo $valid_style;?>状态</a></TH>
		<TH scope=col width="140">操作</TH></TR></THEAD>
<TBODY>
<?php
$tr_class_name  = '';
if(is_array($viewvar['record']) && $viewvar['record'] > 0) {
    foreach($viewvar['record'] as $k=>$v) {
        $tr_class_name  = $tr_class_name != 'tr0' ? 'tr0' : 'tr1';
        if(@(int)$v['lasttime'] == 0) $txt_lasttime = "尚未登录";
        else {
            $txt_lasttime   = date('Y-m-d h:i:s', $v['lasttime']);
            $txt_lasttime   = "<font style=\"font-size:10px\">$txt_lasttime</font>";
        }
        if($v['createtime'] > 0) {
            $txt_createtime = date('Y-m-d', $v['createtime']);
            $txt_createtime = "<font style=\"font-size:10px\">$txt_createtime</font>";
        } else {
            $txt_createtime = '';
        }
        
        $uid    = $v['uid'];
        if($v['valid'] == 1)
            $txt_valid    = "<div class=\"btn_yes\" onclick=\"listTable.toggle(this, 'valid', 1, '$uid', 'u.toggle')\">{$v['valid']}</div>";
        else
            $txt_valid  = "<div class=\"btn_no\" onclick=\"listTable.toggle(this, 'valid', 1, '$uid', 'u.toggle')\">0</div>";
        if($v['qx']==1){
            $txt_qx='省级管理员';
        }elseif($v['qx']==2&&$v['city1']){
            $txt_qx='县级管理员';
        }elseif($v['qx']==2&&$v['city']){
            $txt_qx='市级管理员';
        }elseif($v['qx']==3){
            $txt_qx='站点管理员';
        }else{
            $txt_qx='超级管理员';
        }
?>
	<TR onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);" class="<?php echo $tr_class_name?>">
		<TD width="30" class="textC"><input type="checkbox" value="<?php echo $v['uid']; ?>" name="item_id[]"></TD>
		<TD width="100"><?php echo $v['username']; ?></TD>
		<TD>&nbsp;<?php echo htmlspecialchars($v['realname']); ?></TD>
        <TD><?php echo $txt_qx; ?></TD>
		<TD width="130"><?php echo $txt_lasttime; ?></TD>
		<TD width="80"><?php echo $txt_createtime; ?></TD>
		<TD width="60" class="textc"><?php echo $txt_valid; ?></TD>
		<TD width="140" class="textc">
		<!-- [<a href="<?php echo $mod_url['u.cclass']; ?>&uid=<?php echo $v['uid']; ?>">内容</a>]
		[<a href="<?php echo $mod_url['u.modify']; ?>&uid=<?php echo $v['uid']; ?>">修改</a>] | 
		[<a href="<?php echo $mod_url['u.del']; ?>&item_id=<?php echo $v['uid']; ?>" target="<?php echo $save_frame?>" onclick="return del_this();">删除</a>] -->
        <a href="<?php echo $mod_url['u.modify']; ?>&uid=<?php echo $v['uid']; ?>" class="btn_modify fl" title="修改内容">修改</a> 
		<a href="<?php echo $mod_url['u.del']; ?>&item_id=<?php echo $v['uid']; ?>" target="<?php echo $save_frame?>" onclick="return del_this();" class="btn_del fl" title="删除内容">删除</a>
		</TD></TR>
<?php
    }
} else {
    // 没有记录
}
?>
</TBODY>
</TABLE>
<?php
$page_info  = "共 {$viewvar['record_total']} 条记录 每页 {$viewvar['page_size']} 条 共 {$viewvar['page_total']} 页 ";
$page_list  = get_page_nav($viewvar['page_total']);
?>
<div class="page_nav">
	
	<div class="page_list_pre">
		&nbsp;&nbsp;<a href="javascript:chkbox_sel_all('items_form', 'item_id[]');"><B>全选</B></a> <a href="javascript:chkbox_sel_reverse('items_form', 'item_id[]');"><B>反选</B></a>
	</div>
	<div class="page_list">
		<?php echo $page_list?>
	</div>
	<div class="page_info">
		<?php echo $page_info ?>
	</div>
	<div id="clear_both"></div>
</div>

<div class="new_line borderTop">
<div class="spW10 fl"></div>
<input type="submit" name="del" value="删除" class="btn fl">
<input type="hidden" name="deltype" value="all">
</div>
</form>

</div>
<?php
require($abs_admin_cppath . '/footer.php');
?>